<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 1、使用面向对象中的构造方法以及结合成员方法完成，数组去掉所有0后，生成新的数组输出
        // 数组的内容:
        // let arr = [1, 2, 3, 0, 0, 0, 0];
        let arr = [1, 2, 3, 0, 0, 0, 0];
        let arr1=[];
        for (var i = 0; i < arr.length; i++) {
            
                if (arr[i]!=0) {
                   arr1[arr1.length]=arr[i];
                   
                }
            
        }
        // console.log(arr1)

        class P {
            constructor(arr1) {
                this.arr1 = arr1;
            }

            fn() {

                console.log(arr1);
            }

        }
        let p = new P(arr1);
        p.fn();


    </script>
</body>

</html>